06. Text: ERD 提醒
实体关系图
你可能还记得,在上节课,我们提到 实体关系图 (ERD) 是查看数据库中数据的常见方式。它也是了解如何从多个表格中获取数据的关键要素。
如果能知道 Parch & Posey handy 的 ERD 看起来怎样,会比较有帮助,因此我在下面再次提供了该图。 你甚至可以打印一份,这样在完成剩下的练习时可以参考。

表格与列
在 Parch & Posey 数据库中,有 5 个表格
- web_events
- accounts
- orders
- sales_reps
- region
你将发现,表格中某些列的列名称旁边具有 PK 或 FK ,而其他列根本没有标签。
如果你再仔细观察,可能会发现, PK 在每个表格中与第一列相关。 PK 表示 主键 。 每个表格都存在主键,它是每行的值都唯一的列。
如果你查看我们的数据库中每个表格的前几行,你会发现这个首个
PK
列始终是唯一的。对于此数据库,它始终称为
id
,但并非所有数据库都这样。
Workspace
This section contains either a workspace (it can be a Jupyter Notebook workspace or an online code editor work space, etc.) and it cannot be automatically downloaded to be generated here. Please access the classroom with your account and manually download the workspace to your local machine. Note that for some courses, Udacity upload the workspace files onto https://github.com/udacity , so you may be able to download them there.
Workspace Information:
- Default file path:
- Workspace type: sql-evaluator
- Opened files (when workspace is loaded): n/a